/**
 * @author liyi
 * @desc 获取服务器时间
 */
let serverTimeInterval = null
function getServerTime(response) {
  if (serverTimeInterval) {
    clearInterval(serverTimeInterval)
  }
  window.serverTime = response.headers.date ? new Date(response.headers.date).getTime() : new Date().getTime()
  serverTimeInterval = setInterval(() => {
    window.serverTime = window.serverTime + 1000
  }, 1000)
}
export default getServerTime
